﻿using System.Windows.Interactivity;
using PairingMatrix.ViewModel;

namespace PairingMatrix.View.Behavior
{

    public class TimerMouseClickBehavior : Behavior<TimerControl>
    {
        protected override void OnAttached()
        {
            AssociatedObject.MouseLeftButtonDown += (sender, e) =>
                                                    {
                                                        AssociatedObject.CaptureMouse();
                                                        AssociatedObject.scale.ScaleX = 0.9;                                                        
                                                        AssociatedObject.scale.ScaleY = 0.9;                                                        
                                                    };
 
            AssociatedObject.MouseLeftButtonUp += (sender, e) =>
                                                  {
                                                      AssociatedObject.ReleaseMouseCapture();
                                                      AssociatedObject.scale.ScaleX = 1;
                                                      AssociatedObject.scale.ScaleY = 1;                                                        

                                                      var dataContext = (ITimer)AssociatedObject.DataContext;
                                                      dataContext.ToggleTimerStartStopCommand.Execute(null);
                                                  };
 
        }
    }
}
